home *** CD-ROM | disk | FTP | other *** search
- unit UnitAttachDB;
- (************************************************************************
- This example demonstrates how to use
- the IBStartupParams object,
- the BuildPBnnnnnnn calls to build a Database Parameter Block,
- attaching to a database and
- closing the connection.
- *************************************************************************)
- interface
-
- uses SysUtils, frs_Ibase, frs_Ibase_Object, frs_IBStartParams;
-
- Procedure Open;
- procedure Close;
-
- implementation
-
- procedure SetCoreDetails;
- //Do the basic stuff - get the database name, username and password
- var
- UserName: String;
- Password: String;
- begin
-
- //get dbname etc.
- with IBStartupParams do begin
- frs_GDS.DBName:=IBDatabase;
- UserName:=IBUsername;
- Password:=IBPassword;
- end;
-
- //build dpb
- with frs_GDS do begin
- BuildPBString(FDPB,FDPBLen,isc_dpb_user_name,Username);
- BuildPBString(FDPB,FDPBLen,isc_dpb_password,Password);
- end;
- end;
-
- procedure SetBuffers;
- var
- i: Integer;
- begin
- with IBStartUpParams, frs_GDS do begin
- i:=IBBuffers;
- if i>0 then
- BuildPBInteger(FDPB,FDPBLen,isc_dpb_num_buffers,i);
- end;
- end;
-
- procedure SetRole;
- var
- Role: String;
- begin
- with IBStartUpParams, frs_GDS do begin
- Role:=IBRole;
- if Role<>'' then
- BuildPBString(FDPB,FDPBLen,isc_dpb_sql_role_name,Role);
- end;
- end;
-
- procedure SetCharSet;
- var
- CharSet: String;
- begin
- with IBStartUpParams, frs_GDS do begin
- CharSet:=IBCharSet;
- if CharSet<>'' then
- BuildPBString(FDPB,FDPBLen,isc_dpb_lc_ctype,CharSet);
- end;
- end;
-
- procedure Open;
- begin
- SetCoreDetails;
- SetRole;
- SetCharSet;
-
- SetBuffers;
-
- frs_GDS.DatabaseOpen;
- end;
-
- procedure Close;
- begin
- frs_GDS.DatabaseClose;
- end;
-
- end.
-